package com.sherlockHolmes.init.controller;

import com.sherlockHolmes.init.base.quartz.QuartzService;
import com.sherlockHolmes.init.base.result.Ajax;
import com.sherlockHolmes.init.base.utils.CronUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;

@RestController
@RequestMapping("quartz")
public class QuartzController {
    @Resource
    private QuartzService quartzService;
    @RequestMapping("/test2")
    public Ajax test2()  {
//        String taskCode, String taskName, String cron, String jobGroup,
//        String className, String condition
        try {
            String condition = "清达云，成龙，18:39，44";
            String date = "2024-02-20 18:30:00";
            String s = CronUtil.onlyOnce(date);
            quartzService.startJob("mm", "reminder", s, "reminder",
                    "frame.app.system.task.ArriveMessageTask", condition);
            return Ajax.success("success");
        }catch (Exception e){
            return Ajax.fail(e.getMessage());
        }
    }
}
